load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel:defs.bzl", "rust_bench", "rust_test_suite_with_extra_srcs")

package(default_visibility = [
    "//rs/p2p:__subpackages__",
    "//rs/replica:__subpackages__",
])

DEPENDENCIES = [
    # There should not be any deps from "//rs".
    # If you have to add a new one please consult the NET team.
    "//rs/http_endpoints/async_utils",
    "//rs/crypto/tls_interfaces",
    "//rs/crypto/utils/tls",
    "//rs/interfaces/registry",
    "//rs/monitoring/logger",
    "//rs/monitoring/metrics",
    "//rs/phantom_newtype",
    "//rs/protobuf",
    "//rs/types/base_types",
    "@crate_index//:axum",
    "@crate_index//:bytes",
    "@crate_index//:futures",
    "@crate_index//:http",
    "@crate_index//:prometheus",
    "@crate_index//:prost",
    "@crate_index//:quinn",
    "@crate_index//:rustls",
    "@crate_index//:slog",
    "@crate_index//:socket2",
    "@crate_index//:static_assertions",
    "@crate_index//:thiserror",
    "@crate_index//:tokio",
    "@crate_index//:tokio-metrics",
    "@crate_index//:tokio-util",
    "@crate_index//:tower",
    "@crate_index//:tracing",
]

DEV_DEPENDENCIES = [
    # Keep sorted.
    "//rs/p2p/test_utils",
    "//rs/test_utilities/logger",
    "//rs/types/types_test_utils",
    "@crate_index//:assert_matches",
    "@crate_index//:criterion",
    "@crate_index//:rstest",
    "@crate_index//:turmoil",
]

ALIASES = {}

MACRO_DEPENDENCIES = [
    # Keep sorted.
    "@crate_index//:async-trait",
]

rust_library(
    name = "quic_transport",
    srcs = glob(["src/**/*.rs"]),
    aliases = ALIASES,
    crate_name = "ic_quic_transport",
    proc_macro_deps = MACRO_DEPENDENCIES,
    version = "0.9.0",
    deps = DEPENDENCIES,
)

rust_test(
    name = "quic_transport_test",
    aliases = ALIASES,
    crate = ":quic_transport",
    proc_macro_deps = MACRO_DEPENDENCIES,
    deps = DEPENDENCIES + DEV_DEPENDENCIES,
)

rust_test_suite_with_extra_srcs(
    name = "quic_transport_integration",
    size = "small",
    srcs = glob(
        ["tests/**/*.rs"],
        exclude = ["tests/common.rs"],
    ),
    aliases = ALIASES,
    extra_srcs = ["tests/common.rs"],
    proc_macro_deps = MACRO_DEPENDENCIES,
    deps = [":quic_transport"] + DEPENDENCIES + DEV_DEPENDENCIES,
)

rust_bench(
    name = "quic_transport_bench",
    testonly = True,
    srcs = ["benches/bench.rs"],
    deps = [":quic_transport"] + DEPENDENCIES + DEV_DEPENDENCIES,
)
